Repository navigation
feat(codegen-ts): cover projections, reports, write-through, TPH and m2m in the service - #645
Merged
Merged
Conversation
…oint, and its cost
… interactiveTransactions: false for D1
The generated service committed at its first await on a sync SQLite driver (bun:sqlite,
better-sqlite3), so a refusal answered 409 over a row that stayed. The runtime now drives
those drivers' transaction with BEGIN IMMEDIATE/COMMIT/ROLLBACK, serialized per handle, and
the sqlite Db type accepts a sync driver again. serviceFile({ interactiveTransactions: false })
generates a service with no transaction, hooks or event hook for D1, and refuses a declared
command with ERR_STORE_NO_INTERACTIVE_TX. ADR-0067 section 4 says so.
…and a Hono transport
The generated service (ADR-0067 layer 4) is now held to more of the shared API tests. A shared
integration-tests helper (`api-lane.ts`) boots each generated harness on the flat routes, the
service behind its Fastify transport, or the service behind its Hono transport. list-query,
api-settings, enum-default, jsonb and duration run on all three lanes on every engine their routes
lane runs (D1 through `serviceFile({ interactiveTransactions: false })`). The root corpus and
rules/ also run on Hono, with one actor resolver adapted to each framework's request.
New generator `service-routes-hono` (`serviceRoutesHonoFile()`) writes
`<pkg>/transport/hono.ts`: `<pkg>ServiceHonoRoutes(app, { service, getActor })`, the same routes
as the Fastify transport, through the new `@metaobjectsdev/runtime-ts/service/hono` entry.
Registered in the generator registry, reference templates, the cross-port manifest, and
`meta eject`'s runtime copies. Routes are ordered so a fixed segment precedes a parameter where
two could match one request, since Hono matches in registration order (rules/ public-query found
it). The service compile gate compiles both transports.
Projections, reports, TPH, M:N and write-through on the service, and the decimal and
secret-fields sub-corpora that need them, follow in their own PR.
# Conflicts: # CHANGELOG.md # docs/ports/typescript.md # server/typescript/packages/integration-tests/test/service-compile.test.ts # server/typescript/packages/integration-tests/test/service-sqlite-drivers.test.ts
…om the Fastify mounts
…t helpers, registry README counts
# Conflicts: # fixtures/generator-registry-conformance/README.md # server/typescript/packages/runtime-ts/src/service/hono.ts
… and M:N; write-through on every lane
…orts read through their read model; runGen removes its no-project gen-state at exit
…act ignores import wrapping
…ed operations address its base's table, scoped to its discriminator
…vice's keyed reads and writes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
codegen-tsservice walk now covers every object the flat routes serve. Projections and served reports get list (and get when keyed) operations, reports keep their row cap through the newserviceFile({ reportMaxRows })option, and write-through entities read through their replica view. Single-table (TPH) hierarchies get polymorphic base reads and per-subtype operations scoped to the discriminator, and each many-to-many relationship gets a traversal query. The service templates emit these, and the Fastify and Hono transports answer writes on read-only objects with405.runtime-ts:readOnlyList,readOnlyGetandm2mRelatedare framework-neutral functions inread-only-read.tsandm2m-read.ts. The flat Fastify mounts and the service both call them. Theexamples/owned runtime copies follow.codegen-ts:runGenwith no project removes itsmeta-gen-state-<pid>directory on normal process exit (removeTreeAtExitinscratch-dir.ts), so it no longer accumulates in the scratch root.projection/,report/,write-through/,tph/,m2m/,decimal/andsecret-fields/sub-corpora run on both service lanes. The service compile gate covers a TPH lifecycle fixture. The "not covered yet" list inservice-walk.tsis removed, and docs, ADR-0067 and CHANGELOG are updated.Validation
Risk Assessment
✅ Low: The change meets every numbered intent item. The runtime-ts read extraction is behavior-preserving. The owned example copies are byte-identical to runtime-ts. The new service paths mirror the flat routes' semantics, and I found no reachable wrong-result or authorization path.
Testing
Drove three scenarios against the real codegen-ts and service codegen with real compilers: typed-create compile test now uses scratch dirs and leaves no tmp folders (pass); runGen with no project removes its meta-gen-state directory after process exit (pass, spawns real process); service compile gate builds generated service incl. TPH lifecycle fixture with real TypeScript compiler (40 pass). Not re-run in this turn: service-lane api-contract sub-corpora (report SQLite/D1 405 writes, reportMaxRows, ?format=, Postgres projection/write-through/TPH/M:N/decimal/secret-fields); prior round worker reported 1,095 pass, unverified here. Verdict inconclusive. No background processes left running.
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
server/typescript/packages/integration-tests/test/api-contract-report-sqlite.test.ts- The service-lane api-contract run (report SQLite/D1 + Postgres projection, write-through, TPH, M:N, decimal, secret-fields on the service and service-hono lanes) has no result. The run was stopped by me before it wrote output, so the reader cannot confirm the 405 write behavior, reportMaxRows, or ?format= export on the service lanes. Re-run these api-contract files and record the outcome.bun test test/api-contract-report-sqlite.test.ts test/api-contract-report.test.ts. It was still running after 10 minutes, and I stopped it by PID before it reported. Re-run it without a time lim…scripts/ci-local.sh --affected --strict-toolchainsLive: bun script calling runGen from server/typescript/packages/codegen-ts/src/runner.ts with no projectRoot, DEV_SCRATCH set to a fresh dir under /mnt/scratch, then checked the scratch root after the process exited normallyStartedbun test test/api-contract-report-sqlite.test.ts test/api-contract-report.test.tsin server/typescript/packages/integration-tests; killed by PID before it wrote any results, so no pass/fail outcomeNot run: api-contract projection, write-through, tph, m2m, decimal, secret-fields sub-corpora (Postgres via Docker, both service lanes)Not run: codegen-ts service-compile.test.ts (TPH lifecycle fixture)Not run: full regression suite (cd server/typescript && bun test)🔧 No changes applied.
3 issues (2 errors, 1 warning) still open:
scripts/ci-local.sh --affected --strict-toolchainsstill unresolved. Base attribution says this change introduced it, but the failing lane and test were not identified. Re-run the ts lane alone (ts build and typecheck, conformance: typescript, ts unit suites) to find the failing test. — resolved in a later round: the temp-dir race was fixed in 3fcb389 and the C# conformance lane reran green.MO_CI_LIST_ONLY=1 scripts/ci-local.sh --affected --strict-toolchains) was done. It shows which lanes would run but drives no product behavior, so it does not count as a live pass…scripts/ci-local.sh --affected --strict-toolchainsMO_CI_LIST_ONLY=1 scripts/ci-local.sh --affected --strict-toolchains(lane selection)scripts/ci-local.sh --affected --strict-toolchainsrun in background; no lane completed before the process group was stoppedConfirmed no run processes from this worktree remain after stop🔧 Fix applied.
2 warnings still open:
server/typescript/packages/integration-tests/test/api-contract-report-sqlite.test.ts- Service-lane api-contract sub-corpora (report 405 writes, reportMaxRows cap, ?format= export, projection, write-through, TPH, M:N, decimal, secret-fields on service and service-hono lanes) not re-driven in this turn. Only prior-round worker evidence (1,095 pass) exists. Needs a foreground re-run of these single files to confirm; full-suite re-run not required.scripts/ci-local.sh --affected --strict-toolchainscd server/typescript/packages/codegen-ts && bun test test/typed-create-compile.test.ts test/scratch-dir.test.ts (13 pass, 0 fail)grep for tmp-* dirs in packages/codegen-ts/test after run (0 left)cd server/typescript && bun test packages/integration-tests/test/service-compile.test.ts (40 pass, 0 fail)Baseline from configured command: scripts/ci-local.sh --affected --strict-toolchains (passed per run context; not re-run)✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.